// ListCtrlRoles.cpp: implementation of the CListCtrlRoles class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ListCtrlRoles.h"

#include "eDASexpressApp.h"
extern CEDASexpressApp theApp;

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CListCtrlRoles::CListCtrlRoles()
{
	m_itemdata.m_arrCols = theApp.m_arrRoleCols;

	LoadRoles();
}

CListCtrlRoles::~CListCtrlRoles()
{

}

void CListCtrlRoles::LoadRoles()
{
	if (m_itemdata.m_data.GetSize() > 0)
		m_itemdata.m_data.RemoveAll();
ASSERT(NULL != theApp.m_pRoles);
	POSITION pos= theApp.m_pRoles->m_mapRoles.GetStartPosition();
	while (pos)
	{
		CString strRoleName;
		CStringItemsArray arrAdmittances;
			theApp.m_pRoles->m_mapRoles.GetNextAssoc( pos, strRoleName, arrAdmittances );
		CCopyableArray<CString,LPCTSTR> item;
			item.Add( strRoleName );
			item.Add( arrAdmittances.GetSerialData() );
		m_itemdata.m_data.Add( item );
	}
}

void CListCtrlRoles::RenewRoles()
{
	LoadRoles();

	SetShownData();
}
